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

Revise SDL 0303 - SDL Audio I/O Manager #1165

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions assets/proposals/0303-audio-io-manager/SDLAudioIOManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ typedef NS_ENUM(NSInteger, SDLAudioIOManagerState) {
SDLAudioIOManagerStateStarted = 2,
SDLAudioIOManagerStateStopping = 3, // only for input stream. When waiting for the APT response.
SDLAudioIOManagerStatePausing = 4, // only for input stream. It'll be paused when active and output stream starts
SDLAudioIOManagerStatePaused = 5, // only for input stream while output stream is playing
SDLAudioIOManagerStatePaused = 5, // only for inputstream while output stream is playing
SDLAudioIOManagerStateAborting = 6, // only for inputstream
};

@interface SDLAudioIOManager ()
Expand Down Expand Up @@ -80,7 +81,7 @@ - (instancetype)initWithManager:(SDLManager *)sdlManager delegate:(id<SDLAudioIO
self.operationQueue.suspended = YES;

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onTransportDisconnect) name:SDLTransportDidDisconnect object:nil];

return self;
}

Expand Down Expand Up @@ -174,7 +175,10 @@ - (void)sdl_writeOutputStreamWithFileURL:(NSURL *)fileURL {
}

// in case the input stream is stopping or pausing we will return here and wait until it's fully paused or stopped (there we will start the stream)
if (self.inputStreamState == SDLAudioIOManagerStateStopping || self.inputStreamState == SDLAudioIOManagerStatePausing) {
switch (self.inputStreamState) {
case SDLAudioIOManagerStateStopping:
case SDLAudioIOManagerStatePausing:
case SDLAudioIOManagerStateAborting:
SDLLogV(@"Input stream state is %@. Waiting for input stream transition to be completed.", [self nameForStreamState:self.inputStreamState]);
return;
}
Expand Down Expand Up @@ -586,8 +590,8 @@ - (void)sdl_pauseInputStream {
// if input stream is started or starting we have to send a request to stop it but the status will be pausing (or paused later on)
SDLLogV(@"Input stream state is started. Change state to pausing and send request to end audio input");
self.inputStreamState = SDLAudioIOManagerStatePausing;
[self.sdlManager sendRequest:[[SDLEndAudioPassThru alloc] init]];
[self sdl_initiateAbortInputStreamTimer];
[self.sdlManager sendRequest:[[SDLEndAudioPassThru alloc] init]];
break;
}
default: {
Expand All @@ -606,8 +610,8 @@ - (void)sdl_stopInputStream {
case SDLAudioIOManagerStateStarted: {
SDLLogV(@"Stopping input stream. Sending request to end audio input");
self.inputStreamState = SDLAudioIOManagerStateStopping;
[self.sdlManager sendRequest:[[SDLEndAudioPassThru alloc] init]];
[self sdl_initiateAbortInputStreamTimer];
[self.sdlManager sendRequest:[[SDLEndAudioPassThru alloc] init]];
break;
}
default: {
Expand All @@ -630,9 +634,9 @@ - (BOOL)sdl_abortInputStream {
SDLLogV(@"Attempt to abort input stream from %@", [self nameForStreamState:self.inputStreamState]);

switch (self.inputStreamState) {
case SDLAudioIOManagerStateStarted:
case SDLAudioIOManagerStatePaused:
case SDLAudioIOManagerStateStopped:
SDLLogW(@"Input stream abort not possible when Started or Stopped. Current state %@", [self nameForStreamState:self.inputStreamState]);
SDLLogW(@"Input stream abort not possible when Paused or Stopped. Current state %@", [self nameForStreamState:self.inputStreamState]);
return NO;
}

Expand All @@ -641,10 +645,8 @@ - (BOOL)sdl_abortInputStream {
return NO;
}

// Aborting from Pausing to Paused or Stopping to Stopped is already regular workflow. We need to enforce stopping when we tried to start.
if (self.inputStreamState == SDLAudioIOManagerStateStarting) {
self.inputStreamState = SDLAudioIOManagerStateStopping;
}
// enforce stopping state from any other state (starting, started, pausing, stopping)
self.inputStreamState = SDLAudioIOManagerStateAborting;

SDLPerformAudioPassThruResponse *response = [[SDLPerformAudioPassThruResponse alloc] init];
response.correlationID = self.inputStreamOperation.requests[0].correlationID;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile host="Electron" modified="2021-07-22T06:51:44.489Z" agent="5.0 (Macintosh; Intel Mac OS X 11_4_0) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/14.6.13 Chrome/89.0.4389.128 Electron/12.0.7 Safari/537.36" etag="QtopHjeJ8dBS9GE3bf8M" version="14.6.13" type="device" pages="2"><diagram id="th_HIWHFgpW2jW1lO9Nt" name="Input Stream">7V1bd6O2Fv41WavnwV66cH2cXKaTrsxpOplOO30jBtt0MLiAJ8n8+kqADLrYljGyky77JUEIIdjfvm+JC3y1eP45D5bzj1kYJRcIhM8X+PoCIejbDvlDW17qFt9364ZZHodNp7bhIf4RNY2gaV3FYVRwHcssS8p4yTdOsjSNJiXXFuR59sR3m2YJf9dlMIukhodJkMitf8RhOa9bPRu07R+ieDZnd4agObMIWOemoZgHYfbUacI3F/gqz7Ky/m/xfBUl9OWx91Jf937D2fXE8igtdS74/9P93w8ffiucH7/cPX7+8hD9/oczakb5HiSr5oGbyZYv7A2QUcjLJgeX83KRkDZI/iUPs6TnizLIy4cyKOn5aZwkV1mS5dWFGFQ/2rnMs29R58x02pyRn4FNKMrL6LnT1DzTz1G2iMr8hXRpzloMKQ3A2Ot+aqmFm6Z5h1CsLWjwMVsP3L5C8k/zFvd4o0jjjYYEYs1hlpfzbJalQXLTtnbfNH0TMcHjuySepaTtMSvLbEFORGn4jgKctiXZ5Fvd1HCQVx2R5/mTHICxzQ6/0kN2cP3MHb2sj8L3ccLuv5FERbbKJ9FubBGEzKJySz9c96NvZSvB8ygJyvg7z5gq+jWX3mcxmXILFGRzQIFQgEA90eYqAQXrafQHBrQkZNymMZ3gLRnvV/L3Y5AScZIr8XIXPBLJyiEjaBAxIZQh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