Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New SoundSource/AudioSource API #411

Merged
merged 298 commits into from
Apr 22, 2015
Merged

New SoundSource/AudioSource API #411

merged 298 commits into from
Apr 22, 2015

Conversation

uklotzde
Copy link
Contributor

This is the first step towards a better/cleaner SoundSource API.
The operations for reading audio data have been moved into the
new abstract base class AudioSource.

Currently SoundSource inherits from AudioSource for technical reasons.
This is too much much coupling that needs to be broken up. I have
already some ideas on how to resolve it, but first this work needs to
be integrated.

During the refactoring I've noticed, that the quality and maturity of the
audio decoders for different file types greatly varies:

Good/mature:

  • FLAC
  • Ogg
  • Opus
  • WavPack
  • libsndfile

Mediocre:

  • MP3

Ugly/inefficient:

  • M4A (2014-12-04: Code has been rewritten without legacy code borrowed from other projects)
  • ModPlug

Untested AudioSource API:

  • Apple CoreAudio
  • Windows Media Foundation

Unfinished AudioSource API (just a hack):

  • FFmpeg

Especially the code for the M4A decoder should be revised and cleaned up as
soon as possible, followed by a review of the MP3 decoder. Reading audio
data must work as stable and efficient as possible. This has priority over
the improvement of the internal software architecture!

@ywwg ywwg added this to the 1.13 milestone Nov 29, 2014
@uklotzde
Copy link
Contributor Author

Most of the audio decoders should be in a pretty good condition now:

  • Native floating-point decoding (or conversion from fixed-point if not supported -> MP3)
  • Direct output into sample buffer without temporary buffering (if possible)
  • No memory leaks

I'm already using the new code in "production-like" scenarios (at least M4A, MP3, FLAC), no problems so far.

The following decoders have only been adapted to the new Audio-/SoundSource interfaces, compile without errors, and should (as far as I was able to test it) work:

  • FFmpeg: Still a mess, although it would be great to have a universal interface for different codecs. I've seen there is already work in progress, so I will not touch this code.
  • ModPlug: Legacy stuff. I don't have any plans to touch this code.
  • WindowsMediaFoundation: Out of my scope.
  • CoreAudio: Out of my scope.

@daschuer
Copy link
Member

daschuer commented Jan 7, 2015

OK, probably I should look only on you final result.

#define strncasecmp strnicmp
#endif

#ifdef __M4AHACK__
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this for? Inst uint32_t and unsigned long equal on our target devices?
Please add a comment to the code.

@daschuer
Copy link
Member

daschuer commented Jan 8, 2015

I get a segfault when enabling keylock using soundtouch:

Note: nonZeroCount was 20832, is now 20745
terminate called after throwing an instance of 'std::runtime_error'
what(): SoundTouch : Number of channels not defined

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffefa0f0700 (LWP 5992)]
0x00007ffff17cdbb9 in __GI_raise (sig=sig@entry=6)
at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 ../nptl/sysdeps/unix/sysv/linux/raise.c: Datei oder Verzeichnis nicht gefunden.
(gdb) bt
#0 0x00007ffff17cdbb9 in __GI_raise (sig=sig@entry=6)
at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x00007ffff17d0fc8 in __GI_abort () at abort.c:89
#2 0x00007ffff20d96b5 in __gnu_cxx::__verbose_terminate_handler() ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007ffff20d7836 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007ffff20d7863 in std::terminate() ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ffff20d7aa2 in __cxa_throw ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x00000000004adf5e in soundtouch::SoundTouch::putSamples (
this=, samples=, nSamples=)
at lib/soundtouch-1.8.0/SoundTouch.cpp:302
#7 0x00000000007e83b2 in EngineBufferScaleST::getScaled (this=0x1f61fe0,
buf_size=2048) at src/engine/enginebufferscalest.cpp:152
#8 0x00000000007e3972 in clearScale (this=0x1e5b550)
at src/engine/enginebuffer.cpp:447
#9 EngineBuffer::process (this=0x1e5b550, pOutput=0x7fffb8efd010,
iBufferSize=2048) at src/engine/enginebuffer.cpp:869
#10 0x00000000007e9b68 in EngineDeck::process (this=0x1e3c4f0,
pOut=0x7fffb8efd010, iBufferSize=2048) at src/engine/enginedeck.cpp:92
#11 0x00000000008004d2 in EngineMaster::processChannels (this=this@entry=
0x13dc980,
---Type to continue, or q to quit---
busChannelConnectionFlags=busChannelConnectionFlags@entry=0x7ffefa0ef8f0,
headphoneOutput=headphoneOutput@entry=0x7ffefa0ef860,
iBufferSize=iBufferSize@entry=2048) at src/engine/enginemaster.cpp:286
#12 0x0000000000801114 in EngineMaster::process (this=0x13dc980,
iBufferSize=iBufferSize@entry=2048) at src/engine/enginemaster.cpp:327
#13 0x0000000000a6889b in SoundManager::onDeviceOutputCallback (
this=, iFramesPerBuffer=iFramesPerBuffer@entry=1024)
at src/soundmanager.cpp:483
#14 0x0000000000a62a18 in SoundDevicePortAudio::callbackProcessClkRef (
this=0x1d00370, framesPerBuffer=1024, out=0x3b9bc0a0, in=,
timeInfo=, statusFlags=)
at src/sounddeviceportaudio.cpp:817
#15 0x00007ffff7bb3e63 in ?? ()
from /usr/lib/x86_64-linux-gnu/libportaudio.so.2
#16 0x00007ffff7bb5e20 in ?? ()
from /usr/lib/x86_64-linux-gnu/libportaudio.so.2
#17 0x00007ffff7bbe66e in ?? ()
from /usr/lib/x86_64-linux-gnu/libportaudio.so.2
#18 0x00007ffff31e6182 in start_thread (arg=0x7ffefa0f0700)
at pthread_create.c:312
#19 0x00007ffff1891efd in clone ()
at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

* is moved to the beginning of m_leftoverBuffer, so empty it first (possibly
* with this method). If src and dest overlap, I'll hurt you.
*/
void AudioSourceMediaFoundation::copyFrames(sample_type *dest, size_t *destFrames,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably improve this by using https://github.com/mixxxdj/mixxx/blob/master/src/util/pa_ringbuffer.c
I do not want to put this work on you. So please left a TODO(XXX) here.

@rryan rryan merged commit df73263 into mixxxdj:master Apr 22, 2015
@rryan
Copy link
Member

rryan commented Apr 22, 2015

Doof, I accidentally merged this to master.

@rryan
Copy link
Member

rryan commented Apr 22, 2015

Really sorry about that :(. On the plus side, this branch can now merge to master since we've cut a 1.12 release branch :).

@rryan
Copy link
Member

rryan commented Apr 22, 2015

@uklotzde I sent you a PR that fixes the mac build.

@uklotzde
Copy link
Contributor Author

@rryan Thanks for the OS X fixes! Actually less than I expected :) Should I open a new PR for this branch?

rryan added a commit that referenced this pull request Apr 22, 2015
@rryan
Copy link
Member

rryan commented Apr 22, 2015

@uklotzde -- no need -- just merged to master for real now. Thanks!

@daschuer
Copy link
Member

@uklotzde
Copy link
Contributor Author

The prefix "audioSrcCfg." is missing -> "audioSrcCfg.channelCountHint"

Caused by a last minute change yesterday. I enclosed this configuration
parameter into a struct for better extensibility and control.

On 04/23/2015 07:22 AM, Daniel Schürmann wrote:

This seams to be fail on Window builds. Any idea?
http://builds.mixxx.org/jenkins/job/master/architecture=amd64,platform=windows/lastBuild/consoleFull


Reply to this email directly or view it on GitHub
#411 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants